import Vue from "vue";
import VueRouter from "vue-router";

// import Msite from "../pages/Msite/Msite.vue";
// import Order from "../pages/Order/Order.vue";
// import Profile from "../pages/Profile/Profile.vue";
// import Search from "../pages/Search/Search.vue";
const Msite = ()=> import("../pages/Msite/Msite.vue");
const Order = ()=> import("../pages/Order/Order.vue");
const Profile = ()=> import("../pages/Profile/Profile.vue");
const Search = ()=> import("../pages/Search/Search.vue");

import Login from "../pages/Login/Login.vue";
import Shop from '../pages/Shop/Shop.vue'
import ShopGoods from '../pages/Shop/ShopGoods/ShopGoods.vue'
import ShopRatings from '../pages/Shop/ShopRatings/ShopRatings.vue'
import ShopInfo from '../pages/Shop/ShopInfo/ShopInfo.vue'

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

//声明使用插件
Vue.use(VueRouter);

export default new VueRouter({
  mode:"history",
  routes: [
    { path:"/", redirect:"/msite"},//首页重定向 
    { path: "/msite", 
    component: Msite , //返回路由组件的函数,只有执行此函数才会加载此组件这个函数只有在请求路由路径的时候才会执行
    meta:{showFooter:true}},
    { path: "/order", component: Order ,meta:{showFooter:true}},
    { path: "/profile", component: Profile ,meta:{showFooter:true}},
    { path: "/search", component: Search ,meta:{showFooter:true}},
    { path: "/login", component: Login ,meta:{showFooter:false}},
    { 
      path: "/shop", 
      component: Shop ,
      meta:{showFooter:false},
      children:[
        {path:"",redirect:"/shop/goods"},
        {path:'/shop/goods',component:ShopGoods},
        {path:'/shop/ratings',component:ShopRatings},
        {path:'/shop/info',component:ShopInfo},
      ]
    },
  ]
});
